package com.sunyard.client2.ui;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;

import com.sunyard.client.SunEcmClientApi;
import com.sunyard.client2.ConnectionFactory;
import com.sunyard.client2.conf.ConfUtil;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Model extends JPanel {
	private JTextField textField;

	/**
	 * Create the panel.
	 */
	public Model() {
		setLayout(null);

		JLabel label = new JLabel("模型：");
		label.setBounds(43, 48, 87, 15);
		add(label);

		textField = new JTextField();
		textField.setBounds(156, 45, 283, 21);
		add(textField);
		textField.setColumns(10);
		textField.setText(ConfUtil.getString("modelCode", ""));

		JButton btnNewButton = new JButton("查询");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					SunEcmClientApi clientApi = ConnectionFactory.getConnection();
					String resultMsg = clientApi.getModelTemplate_Client(new String[] { textField.getText() });
					ResultMessageBox.getInstance().showMessage(resultMsg);
				} catch (Exception e1) {
					ResultMessageBox.getInstance().showMessage(e1.getMessage());
				}
			}
		});
		btnNewButton.setBounds(108, 186, 93, 23);
		add(btnNewButton);

	}

}
